// pages/customDetail/customDetail.js
var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        language:{
            'standed_collar': "标准领",
            'cutaway_collar': "八字领",
            'honzcntal_collar': "一字领",
            'button_dawn_collar': "领尖扣领",
            'square_collar': "小方领",
            'round_collar': "圆领",
            'wing_collar': "礼服领",
            'stand_collar': "立领",
            'hidden_button_collar': "暗扣领",
            'large_button_dawn_collar': "大领尖扣领",
            'other': "其他",
            'single_button_cut_angle': "单扣截角",
            'single_button_rand_angle': "单扣圆角",
            'single_button_straight_angle': "单扣直角",
            'dou_cut_angle': "双扣截角",
            'dou_straight_angle': "双扣圆角",
            'dou_straight_straight_angle': "双扣直角",
            'french_cut_angle': "法式截角",
            'french_round_angle': "法式圆角",
            'french_straight_angle': "法式直角",
            'short_sleeve': "短袖",
            'other': "其他",
            'frant_strap': "明门襟",
            'flat_strap': "平门襟",
            'hidden_strap': "暗门襟",
            'other': "其他",
            '0': "否",
            '1': "是",
            'normal': "正体",
            'swash': "花体",
            'italic': "斜体",
            'rat': "鼠",
            'ox': "牛",
            'tiger': "虎",
            'rabbit': "兔",
            'dragon': "龙",
            'snake': "蛇",
            'horse': "马",
            'sheep': "羊",
            'monkey': "猴",
            'chicken': "鸡",
            'dog': "狗",
            'pig': "猪",
            'Aquarius': "水平座",
            'Pisces': "双鱼座",
            'Aries': "白羊座",
            'Taurus': "金牛座",
            'Gemini': "双子座",
            'cancer': "巨蟹座",
            'Leo': "狮子座",
            'Virgo': "处女座",
            'Libra': "天秤座",
            'Scorpio': "天蝎座",
            'Sagittarius': "射手座",
            'Capricorn': "摩羯座"

        }
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var order_id = options.order_id;
        this.get_custom_details(order_id);
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },//获取定制细节
    get_custom_details: function (order_id) {
        var that=this;
        var params = {};
        params['product_id'] = order_id;
        wx.request({
            url: app.config() + "order/orderDetailCustomization",
            data: params,
            header: {
                'content-type': 'application/json'
            },
            success: function (res) {
                var img_url = "http://image.tailorism.com/local/"
                var data = res.data.data;
                var collar = data.goods_collar_mode;//领形
                if (collar == "button_dawn_collar" || collar == "cutaway_collar" || collar == "hidden_button_collar" || collar == "honzcntal_collar" || collar == "round_collar" || collar == "square_collar" || collar == "stand_collar" || collar == "standed_collar" || collar == "wing_collar" || collar == "other" || collar == "large_button_dawn_collar"){
                    var collar_img_url = img_url +"customize/Collar_type/"+ collar+".jpg";
                }
                var sleeve = data.goods_sleeve_mode;//袖形
                if (sleeve == "dou_cut_angle" || sleeve == "dou_straight_angle" || sleeve == "dou_straight_straight_angle" || sleeve == "french_cut_angle" || sleeve == "french_round_angle" || sleeve == "french_straight_angle" || sleeve == "short_sleeve" || sleeve == "single_button_cut_angle" || sleeve == "single_button_rand_angle" || sleeve == "single_button_straight_angle" || sleeve == "other" ){
                    var sleeve_img_url = img_url + "customize/Sleeve/" + sleeve + ".jpg";
                }
                var placket = data.goods_placket;//门襟
                if (placket == "flat_strap" || placket == "frant_strap" || placket == "hidden_strap"){
                    var placket_img_url = img_url + "customize/Placket/" + placket + ".jpg"
                }
                var pocket = data.goods_pocket;//口袋0 -> 否 ， 1 -> 是'
                if (pocket=="0"){
                    var pocket_img_url = img_url + "koudai/wukoudai.jpg";
                } else if (pocket == "1"){
                    var pocket_img_url = img_url + "koudai/youkoudai.jpg";
                }

                var white_collar_white_sleeve = data.goods_white_collar_white_sleeve;//白领白袖0 -> 否 ， 1 -> 是',                
                // http://image.tailorism.com/local/fblbx.jpg
                if (white_collar_white_sleeve=="0"){
                    var white_collar_white_sleeve_img_url = img_url + "fblbx.jpg";
                } else if (white_collar_white_sleeve == "1"){
                    var white_collar_white_sleeve_img_url = img_url + "blbx.jpg";
                }
                var live_insert = data.live_insert;//插片
                if (live_insert=="无插片"){
                    var live_insert_img_url = img_url + "chapian/wuchapian.jpg";
                }else if(live_insert=="固定插片"){
                    var live_insert_img_url = img_url + "chapian/gudingchapian.jpg";
                } else if (live_insert == "活插片") {
                    var live_insert_img_url = img_url + "chapian/huolingchapian.jpg";
                }
                var waist_dart = data.waist_dart;//收腰省0 -> 否 , 1 -> 是',
                if (waist_dart=="0"){
                    var waist_dart_img_url = img_url + "ys/wys.jpg";
                } else if (waist_dart == "1"){
                    var waist_dart_img_url = img_url + "ys/yys.jpg";
                }
                var embroidered = data.embroidered;//'是否绣字：0 -> 不绣字 ， 1 -> 绣字',
                var embroidered_text = data.embroidered_text;//绣字内容
                var embroidered_font = data.embroidered_font;//绣字字体
                if (embroidered_font == "normal" || embroidered_font == "swash" || embroidered_font == "italic"){
                    var embroidered_font_img_url = img_url + "customize/" + embroidered_font+".jpg"
                }
                var embroidered_color = data.embroidered_color;//绣字颜色
                var embroidered_color = data.embroidered_color;//绣字颜色
                if (embroidered_color == "品牌色" || embroidered_color == "白色（HTP）" || embroidered_color == "深蓝色(218)" || embroidered_color == "银灰色(606)" || embroidered_color == "绿色(54)" || embroidered_color == "黑色(426)" || embroidered_color == "酒红色(155)" || embroidered_color == "大红色(518)" || embroidered_color == "顺色" || embroidered_color == "金色(120)" || embroidered_color == "棕色(568)"){
                    var embroidered_color_img_url = img_url + "color/" + embroidered_color + ".jpg";
                }
                var embroidered_location = data.embroidered_location;//绣字位置
                if (embroidered_location == "口袋沿" || embroidered_location == "领座" || embroidered_location == "门襟下摆" || embroidered_location == "右领口" || embroidered_location == "右袖口" || embroidered_location == "右中腰" || embroidered_location == "左领口" || embroidered_location == "左前胸" || embroidered_location == "左袖口" || embroidered_location == "左中腰" ){
                    var embroidered_location_img_url = img_url + "location/" + embroidered_location + ".jpg";
                }
                var constellation = data.constellation;//是否星座绣花
                var embroidered_constellation = data.embroidered_constellation;//星座绣花
                if (embroidered_constellation == "Aries" || embroidered_constellation == "Taurus" || embroidered_constellation == "Gemini" || embroidered_constellation == "cancer" || embroidered_constellation == "Leo" || embroidered_constellation == "Virgo" || embroidered_constellation == "Libra" || embroidered_constellation == "Scorpio" || embroidered_constellation == "Sagittarius" || embroidered_constellation == "Capricorn" || embroidered_constellation == "Aquarius" || embroidered_constellation == "Pisces" ){
                    var embroidered_constellation_img_url = img_url + "xz/" + embroidered_constellation + ".jpg";
                }
                var constellation_color = data.constellation_color;//星座颜色
                if (constellation_color == "品牌色" || constellation_color == "白色（HTP）" || constellation_color == "深蓝色(218)" || constellation_color == "银灰色(606)" || constellation_color == "绿色(54)" || constellation_color == "黑色(426)" || constellation_color == "酒红色(155)" || constellation_color == "大红色(518)" || constellation_color == "顺色" || constellation_color == "金色(120)" || constellation_color == "棕色(568)"){
                    var constellation_color_img_url = img_url + "color/" + constellation_color + ".jpg";
                }
                var constellation_location = data.constellation_location;//星座位置
                if (constellation_location == "口袋" || constellation_location == "领座" || constellation_location == "门襟下摆" || constellation_location == "右领口" || constellation_location == "右袖口" || constellation_location == "右中腰" || constellation_location == "左领口" || constellation_location == "左前胸" || constellation_location == "左袖口" || constellation_location == "左中腰" ) {
                    var constellation_location_img_url = img_url + "location/" + constellation_location + ".jpg";
                }
                var zodiac = data.zodiac;//是否生肖绣花
                var embroidered_zodiac = data.embroidered_zodiac;//生肖绣花
                if (embroidered_zodiac == "rat" || embroidered_zodiac == "ox" || embroidered_zodiac == "tiger" || embroidered_zodiac == "rabbit" || embroidered_zodiac == "dragon" || embroidered_zodiac == "snake" || embroidered_zodiac == "horse" || embroidered_zodiac == "sheep" || embroidered_zodiac == "monkey" || embroidered_zodiac == "chicken" || embroidered_zodiac == "dog" || embroidered_zodiac == "pig"){
                    var embroidered_zodiac_img_url = img_url + "sx/" + embroidered_zodiac + ".jpg";
                }
                var zodiac_color = data.zodiac_color;//生肖颜色
                if (zodiac_color == "品牌色" || zodiac_color == "白色（HTP）" || zodiac_color == "深蓝色(218)" || zodiac_color == "银灰色(606)" || zodiac_color == "绿色(54)" || zodiac_color == "黑色(426)" || zodiac_color == "酒红色(155)" || zodiac_color == "大红色(518)" || zodiac_color == "顺色" || zodiac_color == "金色(120)" || zodiac_color == "棕色(568)") {
                    var zodiac_color_img_url = img_url + "color/" + zodiac_color + ".jpg";
                }
                var zodiac_location = data.zodiac_location;//生肖位置
                if (zodiac_location == "口袋" || zodiac_location == "领座" || zodiac_location == "门襟下摆" || zodiac_location == "右领口" || zodiac_location == "右袖口" || zodiac_location == "右中腰" || zodiac_location == "左领口" || zodiac_location == "左前胸" || zodiac_location == "左袖口" || zodiac_location == "左中腰") {
                    var zodiac_location_img_url = img_url + "location/" + zodiac_location + ".jpg";
                }
                that.setData({
                    collar_img_url: collar_img_url,
                    sleeve_img_url: sleeve_img_url,
                    placket_img_url: placket_img_url,
                    pocket_img_url: pocket_img_url,
                    white_collar_white_sleeve_img_url: white_collar_white_sleeve_img_url,
                    white_collar_white_sleeve: white_collar_white_sleeve,
                    live_insert_img_url: live_insert_img_url,
                    waist_dart_img_url: waist_dart_img_url,
                    embroidered: embroidered,
                    embroidered_text:embroidered_text,
                    embroidered_font_img_url: embroidered_font_img_url,
                    embroidered_color_img_url: embroidered_color_img_url,
                    embroidered_location_img_url: embroidered_location_img_url,
                    embroidered_constellation_img_url: embroidered_constellation_img_url,
                    constellation_color_img_url: constellation_color_img_url,
                    constellation_location_img_url: constellation_location_img_url,
                    embroidered_zodiac_img_url: embroidered_zodiac_img_url,
                    zodiac_color_img_url: zodiac_color_img_url,
                    zodiac_location_img_url: zodiac_location_img_url,
                    
                    collar: that.data.language[collar],
                    sleeve: that.data.language[sleeve],
                    placket: that.data.language[placket],
                    pocket: that.data.language[pocket],
                    white_collar_white_sleeve: that.data.language[white_collar_white_sleeve] ,
                    white_collar_white_sleeve: that.data.language[white_collar_white_sleeve],
                    live_insert : live_insert ,
                    waist_dart : that.data.language[waist_dart] ,
                    embroidered: embroidered,
                    embroidered_text:embroidered_text,
                    embroidered_font : that.data.language[embroidered_font] ,
                    embroidered_color : embroidered_color,
                    embroidered_location: embroidered_location,
                    embroidered_constellation: that.data.language[embroidered_constellation],
                    constellation: constellation,
                    constellation_color: constellation_color,
                    constellation_location: constellation_location,
                    embroidered_zodiac: that.data.language[embroidered_zodiac],
                    zodiac_color: zodiac_color,
                    zodiac_location: zodiac_location,
                    zodiac: zodiac


                })
            }
        })
    }
})